#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=200050;
int read(){
    int f=1;int m=0;char c=getchar();
    while((c<'0'||c>'9')){if(c=='-')f=-1;c=getchar();}
    while(!(c<'0'||c>'9')){m=m*10+(c-'0');c=getchar();}
    return m*f;
}
bool cmp(pair<int,int> a,pair<int,int> b){
    if(a.second!=b.second)return a.second<b.second;
    return a.first<b.first;
}
int n,m;
double p[maxn];
double d[maxn];
double a[maxn];
double v[maxn];
pair<int,int> ti[maxn];
pair<int,int> t[maxn];
double L;
double V;
int cnt;
void solve(){
    n=read(),m=read();
    L=read(),V=read();
    cnt=0;
    for(int i=1;i<=n;i++){
        d[i]=read();
        v[i]=read();
        a[i]=read();
        
    }
    for(int i=1;i<=m;i++){
        p[i]=read();
    }p[m+1]=L+1;
    for(int i=1;i<=n;i++){
        if(a[i]>=0){
            if(d[i]>p[m]){
                ti[i].first=m+1;
                ti[i].second=m+1;
                continue ;
            }
            if(v[i]>V){
                ti[i].first=lower_bound(p+1,p+m+2,d[i])-p;
                ti[i].second=m;
                continue ;
            }
            double s=p[m]-d[i];
            double v1=v[i]*v[i]+2*a[i]*s;
            v1=sqrt(v1);
            if(v1<=V){
                ti[i].first=m+1;
                ti[i].second=m+1;
                continue ;
            }
            double s1=V*V-v[i]*v[i];
            s1/=(2*a[i]);
            s1+=d[i];
            ti[i].first=upper_bound(p+1,p+m+2,s1)-p;
            ti[i].second=m;
        }else {
            if(v[i]<=V){
                ti[i].first=m+1;
                ti[i].second=m+1;
                continue ;
            }
            int pos=lower_bound(p+1,p+m+2,d[i])-p;
            if(pos>m){
                ti[i].first=m+1;
                ti[i].second=m+1;
                continue ;
            }
            double s1=V*V-v[i]*v[i];
            s1/=(2*a[i]);
            s1+=d[i];
            if(s1<=p[pos]){
                ti[i].first=m+1;
                ti[i].second=m+1;
                continue ;
            }
            ti[i].first=pos;
            ti[i].second=lower_bound(p+1,p+m+2,s1)-p;
            // if(p[ti[i].second]==s1)
            ti[i].second--;
        }
    }
    for(int i=1;i<=n;i++){
        if(ti[i].first==m+1)continue ;
        ++cnt;
        t[cnt].first=ti[i].first;
        t[cnt].second=ti[i].second;
        // cout<<i<<' '<<ti[i].first<<' '<<ti[i].second<<'\n';
    }
    sort(t+1,t+cnt+1,cmp);

    // cout<<'\n';
    // for(int i=1;i<=cnt;i++){
    //     cout<<t[i].first<<' '<<t[i].second<<"\n";
    // }cout<<'\n';

    int las=-1;int ans=0;
    for(int i=1;i<=cnt;i++){
        if(t[i].first>las){
            las=t[i].second;
            ans++;
        }
    }ans=m-ans;
    cout<<cnt<<' '<<ans<<'\n';
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    T=read();
    while(T--){
        solve();
    }
    return 0;
}